package interview_questions;

import java.util.Scanner;

public class Main1_6 {
	public static void rotate(int[][] matrix, int n) {
		for (int layer = 0; layer < n/2; layer++) {
			int first = layer;
			int last = n - 1 - layer;
			for (int i = first; i < last; i++) {
				int offset = i - first;
				// 存储上边
				int top = matrix[first][i];
				// 左到上
				matrix[first][i] = matrix[last-offset][first];
				// 下到左
				matrix[last-offset][first] = matrix[last][last-offset];
				// 右到下
				matrix[last][last-offset] = matrix[i][last];
				// 上到右
				matrix[i][last] = top;
			}
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] matrix = new int[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				matrix[i][j] = i * n + j + 1;
		rotate(matrix, n);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				System.out.print(matrix[i][j] + " ");
			System.out.println();
		}
	}
}
